/* License Notice:
**
** This program is free software: you can redistribute it and/or modify
**    it under the terms of the GNU General Public License as published by
**    the Free Software Foundation, either version 3 of the License, or
**    (at your option) any later version.
** This program is distributed in the hope that it will be useful,
**   but WITHOUT ANY WARRANTY; without even the implied warranty of
**   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
**   GNU General Public License for more details.
** You should have received a copy of the GNU General Public License
**   along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/**
 * @file input_device.hpp
 * @author TooOld2Rock'nRoll
 * @date 2024/05/03
 * @remark Last modified in 2024/05/03
 * @brief Defines common structures to all input devices.
 *
 * @todo Key modifiers must be absorbed and isolated from SDL.
 */
#ifndef _INPUT_DEVICE_HPP_
#define _INPUT_DEVICE_HPP_

/*---- Includes ----*/


/*---- Structures ----*/
/** @brief State of hardware clicky things like buttons. */
enum key_state
{
    UP = 0, ///<Key was released or just not pressed (same as SDL_RELEASED).
    DOWN,   ///<Key was pressed (same as SDL_PRESSED).
    HOLD,   ///<Key is being hold down (SDL does have a repeat state, but triggers sporadically).
    _key_state_max///<Keeps track of enum size
};//key_state


/*---- Class Declaration ----*/
/**
 * @brief Interface to a input device.
 * @tparam K - the InputDevice key indexing data type.
 */
template <typename K>
class InputDevice
{
    private:


    protected:
        ///How many clicky things this device has.
        unsigned u_key_count = 0;


    public:
        /** @brief Base Constructor.  */
        InputDevice () {  }
        /** @brief Destructor.  */
        virtual ~InputDevice () {  }

        /** @brief Returns the total number of keys this device has. */
        unsigned getNumberOfKeys () { return this->u_key_count; }

        /** @brief Updates the imediate device state. */
        virtual void update () = 0;

        /** @brief Returns a reference to the desired key state since last update. */
        virtual key_state getKeyState (K key_index) const = 0;
};//END InputDevice

#endif //_INPUT_DEVICE_HPP_

